﻿using System;
using System.Collections.Generic;
using System.Text;
using WebApiV4Test.Data.Entity;
using WebApiV4Test.Domain.Enum;
using WebApiV4Test.Interface.Log;

namespace WebApiV4Test.Utils.Log
{
   public static class LogHelper
    {
         public static void Logger(this ILog log, Exception exception, LogsLevel logsLevel, int usersId)
        {
            var item = new Logs
            {
                LogLevel = (int)logsLevel,
                ShortMessage = exception.Message,
                FullMessage = exception.ToString(),
                UserId = usersId,
            };
            log.Insert(item);
        }
        public static void Info(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.信息, int usersId = 0)
        {
            Logger(log, exception, logsLevel, usersId);
        }

        public static void Debug(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.调试, int usersId = 0)
        {
            Logger(log, exception, logsLevel, usersId);
        }

        public static void Error(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.错误, int usersId = 0)
        {
            Logger(log, exception, logsLevel, usersId);
        }
        public static void Fatal(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.崩溃, int usersId = 0)
        {
            Logger(log, exception, logsLevel, usersId);
        }

    }
}
